package Tables;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class Course_Center extends Table{
    private int student_id;
    private String student_name;
    private int course_id;
    private String course_name;
    public Course_Center(Connection connection) {
        super(connection);
    }

    @Override
    public String toString() {
        return "Course_Center{" +
                "student_id=" + student_id +
                ", student_name='" + student_name + '\'' +
                ", course_id=" + course_id +
                ", course_name='" + course_name + '\'' +
                '}';
    }

    public int getStudent_id() {
        return student_id;
    }

    public void setStudent_id(int student_id) {
        this.student_id = student_id;
    }

    public String getStudent_name() {
        return student_name;
    }

    public void setStudent_name(String student_name) {
        this.student_name = student_name;
    }

    public int getCourse_id() {
        return course_id;
    }

    public void setCourse_id(int course_id) {
        this.course_id = course_id;
    }

    public String getCourse_name() {
        return course_name;
    }

    public void setCourse_name(String course_name) {
        this.course_name = course_name;
    }

    @Override
    public List<String> get() throws SQLException {
        String order = "select * from course_center";
        PreparedStatement statement = this.connection.prepareStatement(order);
        ResultSet set = statement.executeQuery();
        while(set.next()){
            this.student_id = set.getInt(1);
            this.student_name = set.getString(2);
            this.course_id = set.getInt(3);
            this.course_name = set.getString(4);
            this.tableList.add(toString());
        }
        return this.tableList;
    }
}
